<?
require_once("base/BaseGuideForm.php");
require_once("cms/guide/om/Guide.php");
require_once("cms/core/om/Image.php");

class GuideForm extends BaseGuideForm {

    private $log;
    private $language;

    public function __construct() {
        parent::__construct();
        $this->log =& LoggerManager::getLogger("GuideForm");
        $this->getGuideI18n()->setGuide(new Guide());
        $this->getGuideI18n()->getGuide()->setImageRelatedByImageId(new Image());
        $this->getGuideI18n()->getGuide()->setImageRelatedByThumbnailId(new Image());
    }

    public function reset(ActionConfig $mapping, Request $request) {
        $this->language = $request->getContext()->getInitParameter(
            _Core::DEFAULT_LANGUAGE);
    }

    public function validate() {

        global $ALLOWABLE_IMAGES;

        $ALLOWABLE_IMAGES = array(
            "image/jpeg"=>"jpg",
            "image/pjpeg"=>"jpg",
            "image/gif"=>"gif",
            "image/png"=>"png"
        );

        $errors = parent::validate();

        if($this->getGuideI18n()->getLanguageCode() == $this->language) {

            if(strlen($this->getGuideI18n()->getGuide()->getCountryCode()) == 0)
                $errors->add("guideI18n->guide->countryCode",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.country", true)));


        }

        return $errors;
    }

}
?>